<?php

/**
 * Category form base class.
 *
 * @method Category getObject() Returns the current form's model object
 *
 * @package    symfony
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseCategoryForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                   => new sfWidgetFormInputHidden(),
      'title'                => new sfWidgetFormInputText(),
      'creation_user_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser01'), 'add_empty' => true)),
      'modification_user_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser02'), 'add_empty' => true)),
      'type'                 => new sfWidgetFormChoice(array('choices' => array('menu' => 'menu', 'footer' => 'footer', 'photo' => 'photo', 'video' => 'video', 'document' => 'document', 'news' => 'news'))),
      'category_parent_id'   => new sfWidgetFormInputText(),
      'link'                 => new sfWidgetFormInputText(),
      'num_order'            => new sfWidgetFormInputText(),
      'publication'          => new sfWidgetFormChoice(array('choices' => array('published' => 'published', 'notPublished' => 'notPublished', 'published only members' => 'published only members'))),
      'slug'                 => new sfWidgetFormInputText(),
      'created_at'           => new sfWidgetFormDateTime(),
      'updated_at'           => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                   => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'title'                => new sfValidatorString(array('max_length' => 255)),
      'creation_user_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser01'), 'required' => false)),
      'modification_user_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser02'), 'required' => false)),
      'type'                 => new sfValidatorChoice(array('choices' => array(0 => 'menu', 1 => 'footer', 2 => 'photo', 3 => 'video', 4 => 'document', 5 => 'news'), 'required' => false)),
      'category_parent_id'   => new sfValidatorInteger(array('required' => false)),
      'link'                 => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'num_order'            => new sfValidatorInteger(array('required' => false)),
      'publication'          => new sfValidatorChoice(array('choices' => array(0 => 'published', 1 => 'notPublished', 2 => 'published only members'), 'required' => false)),
      'slug'                 => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'created_at'           => new sfValidatorDateTime(),
      'updated_at'           => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Category', 'column' => array('slug')))
    );

    $this->widgetSchema->setNameFormat('category[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Category';
  }

}
